import request from '@/plugins/request'

import qs from 'qs'
import CryptoJS from 'crypto-js';
import Setting from '@/setting'

export function encrypt (content, key) {
    var sKey = CryptoJS.enc.Utf8.parse(key);
    var sContent = CryptoJS.enc.Utf8.parse(content);
    var encrypted = CryptoJS.AES.encrypt(sContent, sKey, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 });
    return encrypted.toString();
}
export function AccountLogin (data) {
    data.pwd = encrypt(data.pwd, 'bbcjy20200701160')

    return request({
        url: Setting.apiBaseURL + '/sysback/login/doLogin',
        method: 'post',
        data: qs.stringify(data),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

export function AccountRegister (data) {
    return request({
        url: '/api/register',
        method: 'get',
        data: qs.stringify(data)
    })
}
